﻿#region ExcuteHalconProc_MultiThreadParameter_Xml.cs
// ============================================================================
// This region will be filled automatically with data if you are working
// for example with Microsoft SourceSafe
//
// Purpose:          
// Specifics: 
// 
// Creation date:    2024/5/27 14:21:44
// Created by:       hao.chen
//
// $Author:        $
// $Date:          $
// $Revision:      $
// $History:       $
// $NoKeywords:    $
// 
// Copyright:      © 2024 YourCompanyName
//                 All Rights Reserved
// ============================================================================
#endregion

using NeuroCheck.PlugInLib.Base;
using System;
using System.Text;
using System.Xml;

// TODO: Namespace - Modify the namespace to the project namespace
namespace CLVisionHalconNC620
{
    /// <summary>This file contains the code is necessary to serialize and deserialize the parameters
    /// of the plug-in check function "ExcuteHalconProc_MultiThread". This data are the base for storing and loading
    /// the plug-in check function parameters in the xml CHRX-file (check routine file).
    /// </summary>
    /// <remarks>It is recommended to serialize only necessary data and none that is created at runtime.
    /// </remarks>
	public partial class ExcuteHalconProc_MultiThreadParameter
    {
     

        /// <summary>Exports data to the NeuroCheck xml CHRX-file (check routine file).
        /// </summary>
        /// <param name="xmlDom">NcPIXmlService.</param>
        /// <param name="xnode0">XmlNode the data will be stored in.</param>
        public override void DumpAsXml(NcPIXmlService xmlDom, XmlNode xnode0)
        {
            try
            {
                // Version number
                xmlDom.CreateAttribute(xnode0, Globals.XmlArrtibuteVersion, m_CurrentVersion.ToString());

            } // eof try
            catch (NcPIApiException ex)
            {
                NcPIUserException newEx = new NcPIUserException(ex.Message);
                throw newEx;

            } // eof catch
            catch (Exception ex)
            {
                NcPIUserException newEx = new NcPIUserException(ex.Message);
                throw newEx;

            } // eof catch
        }

        /// <summary>Imports data from the NeuroCheck xml CHRX-file (check routine file).
        /// </summary>
        /// <param name="xmlDom">NcPIXmlService.</param>
        /// <param name="xnode0">XmlNode the data will be restored from.</param>
        public override void RestoreFromXml(NcPIXmlService xmlDom, XmlNode xnode0)
        {
            // Help variables
            bool throwException = true;
            string message;

            try
            {
                #region --- Version verification ---

                // Version number
                string stringVersion = xmlDom.GetAttributeValueAsString(xnode0, Globals.XmlArrtibuteVersion);
                m_SerializationVersion = Globals.GetVersionFromString(stringVersion);

                // Verify the serialized class version
                // The minimum supported version is 6.2.0.0 and maximum the current version of this class. It is not the version from AssemblyInfo.cs.
                // This verification prevents the deserialization of data created by class version 6.2.1.0 if this code supports version 6.2.0.0 only.
                if ((m_SerializationVersion >= new Version(6, 2, 0, 0)) &&
                    (m_SerializationVersion <= m_CurrentVersion))
                {
                    // Version of this class is at least 6.2.0.0, this is OK
                    throwException = false;

                } // eof if

                // Check if an exception should be thrown
                if (true == throwException)
                {
                    message = String.Format(Properties.GlobalResources.strVersionIsNotSupported,
                                            Properties.ExcuteHalconProc_MultiThreadResources.strCheckFunctionName,
                                            stringVersion,
                                            m_CurrentVersion.ToString());
                    NcPIUserException newEx = new NcPIUserException(message);
                    throw newEx;

                } // eof if

                #endregion --- Version verification ---

                // TODO: XmlSerialization - Import check function parameters
                // Example:
                // Offset-X 100101
                // m_OffsetX = xmlDom.GetParaChildNodeValueAsInt(xnode0, (int)ExcuteHalconProc_MultiThreadXmlNodeIDsInfo.OffsetX);

            } // eof try
            catch (NcPIApiException ex)
            {
                NcPIUserException newEx = new NcPIUserException(ex.Message);
                throw newEx;

            } // eof catch
            catch (Exception ex)
            {
                NcPIUserException newEx = new NcPIUserException(ex.Message);
                throw newEx;

            } // eof catch
        }

     

    } // end of class
} // end of namespace